// Fill out your copyright notice in the Description page of Project Settings.


#include "MyHUD.h"
#include "MyQuadtreeNodeManager.h"
#include "MyQuadtreeNode.h"
#include "Kismet/KismetSystemLibrary.h"

AMyHUD::AMyHUD()
{
	
}

void AMyHUD::DrawTreeLine(AMyQuadtreeNodeManager* target,bool isTypeA,FLinearColor color,float lifetime,float thickness)
{
	if(target)
	{
		if(isTypeA)
		{
			for(FQuad_TreeNode* node:target->QuadtreeNodeA->AllNodes)
			{
				if(node)
				{
					FVector pos1(node->start_xy,0);
					FVector pos2(node->start_xy.X+node->width,node->start_xy.Y,0);
					FVector pos3(node->start_xy.X+node->width,node->start_xy.Y+node->height,0);
					FVector pos4(node->start_xy.X,node->start_xy.Y+node->height,0);
	
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos1,pos2,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos2,pos3,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos3,pos4,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos4,pos1,color,lifetime,thickness);
				}
			}
		}
		else
		{
			for(FQuad_TreeNode* node:target->QuadtreeNodeB->AllNodes)
			{
				if(node)
				{
					FVector pos1(node->start_xy,0);
					FVector pos2(node->start_xy.X+node->width,node->start_xy.Y,0);
					FVector pos3(node->start_xy.X+node->width,node->start_xy.Y+node->height,0);
					FVector pos4(node->start_xy.X,node->start_xy.Y+node->height,0);
	
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos1,pos2,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos2,pos3,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos3,pos4,color,lifetime,thickness);
					UKismetSystemLibrary::DrawDebugLine(GetWorld(),pos4,pos1,color,lifetime,thickness);
				}
			}
		}
	}
}

void AMyHUD::BeginPlay()
{

	Super::BeginPlay();
}
